#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

struct dic {
    string word;
    int frequency;
    dic(const string& w, int f) : word(w), frequency(f) {}
    
    // 按照频率降序排序，如果频率相同则按字典序升序排序
    bool operator < (const dic& other) const {
        if (frequency != other.frequency) {
            return frequency > other.frequency;
        }
        return word < other.word;
    }
};
struct trienode{
    trienode * children[36];
    bool end;
    int freq;
    trienode():end(false),freq(0){
        for(int i=0;i<36;i++)children[i]=NULL;
    }
};
int charzh(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    } else {
        return c - 'a' + 10;
    }
}
void insert(trienode * root,int freq,const string & word){
    trienode * node =root;
    for(char c:word){//
        int i=charzh(c);
        if(!node->children[i]){
            node->children[i]=new trienode();
        }
        node=node->children[i];
    }
    node->end=true;//标记单词结束
    node->freq=max(node->freq,freq);
}
void cz(trienode *root,const string & qz,string dq,vector<dic>&ans){
    if(root->end){
        if(dq.length()>qz.length()){
            ans.emplace_back(dq,root->freq);
        }//只有是单词才进行是否与前缀重合判断
}
for(int i=0;i<36;i++){
    if(root->children[i]){
        char nxt;
        if(i<10){
            nxt='0'+i;
        }
         else {
            nxt='a'+(i-10);
        }
        cz(root->children[i],qz,dq+nxt,ans);
    }
}
}
vector<dic>czw(trienode *root,const string &qz){
    vector<dic>v;
    trienode * node=root;
    for(char c:qz){
        int i=charzh(c);
        if(!node->children[i]){
            return v;//查询失败
        }
        node=node->children[i];
    }
    cz(node,qz,qz,v);
    return v;
}
int main() {
    int n, m, k;
    cin >> n >> m >> k;
    trienode * root=new trienode();
    // 读入字典
    for (int i = 0; i < n; i++) {
        int freq;
        char word1[50];
        scanf("%d%s",&freq,word1);
        string word(word1);
        insert(root,freq,word);
    }
    
    // 用户查询
    for (int i = 0; i < m; i++) {
        char  cx1[25];
        scanf("%s",cx1);
        string cx(cx1);
        vector<dic>ans=czw(root,cx);
        sort(ans.begin(),ans.end());
        if(ans.empty()){
            printf("no suggestion\n");
        } else {
            int outcnt=min(k,int(ans.size()));
            for(int j=0;j<outcnt;j++)printf("%s\n",ans[j].word.c_str());
        }
        if(i<m-1)printf("\n");
    }
    return 0;
}